<?php @session_start();?>
<?php
require_once('./safe.php');
require_once('../admin/config.php');
$conn = mysql_connect($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd);
mysql_select_db($cfg_dbname,$conn);
$sql="select * from ph_user where user_name='".$_SESSION["username"]."'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$sqltdk="select * from ph_tdk where 1=1";
$resulttdk=mysql_query($sqltdk);
$rowtdk=mysql_fetch_array($resulttdk);
function check($str){
    return str_replace("'","''",$str);
}

$Status=check($_GET["Status"]);

$sqla="select * from ph_order where userid='".$_SESSION["userid"]."'";
IF(!empty($Status)){$sqla.=" and Status='".$Status."'";}
$resulta=mysql_query($sqla);

?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

        <link rel="apple-touch-icon" sizes="180x180" href="/images/iosinstalls/favicon/apple-touch-icon.png">

        <meta name="theme-color" content="#ffffff">

        <title><?php echo $rowtdk["sitename"];?> - Dashboard</title>

        <link href="../css/customer-iosinstalls.css?id=a9a9c5930bcdb195e9ee" rel="stylesheet">
        <link rel="stylesheet" type="text/css" href="<?php if(!empty($rowtdk["fontlink"])){echo '//fonts.googleapis.com/css?family='.$rowtdk["fontlink"];}else{echo "//fonts.googleapis.com/css?family=Roboto:300,400,500";}?>">
        <style type="text/css">
            body{font-family: '<?php echo $rowtdk["fontlink"];?>';}
        </style>
        <script type="text/javascript">
function setsize(v1){
var labels = document.getElementById("rdddd").getElementsByTagName("label");
var radios = document.getElementById("rdddd").getElementsByTagName("input");

for(t=0,y=labels.length; t<y; t++)
{
      if(labels[t].id==v1){
      labels[t].className='black';
      radios[t].checked=true;
      }else{
      labels[t].className='';
      radios[t].checked=false;

}
 }
 }

 function setsize2(v1){
var labels = document.getElementById("rddddc").getElementsByTagName("label");
var radios = document.getElementById("rddddc").getElementsByTagName("input");

for(t=0,y=labels.length; t<y; t++)
{
      if(labels[t].id==v1){
      labels[t].className='black';
      radios[t].checked=true;
      }else{
      labels[t].className='';
      radios[t].checked=false;

}
 }
 }
</script>
<style type="text/css">
<!--
.pay_fun {
    position: relative;
    list-style: none;
    padding: 0px;
    margin: 0px;
}
.pay_fun label {
    border: 2px solid #ccc;
    width: 24%;
    background: #fff;
    margin-top: 5px;
    margin-left: 5px;
    list-style: none;
    float: left;
    font-size: 14px;
    padding: 10px;
    text-align: center;
}
.pay_fun label:hover {
    cursor: pointer;
    border: 2px solid #0099CC;
}
.black {
    border: 2px solid #0099CC !important;
    background-position: 90px 20px !important;
    background-color: #0099CC !important;
    color: #fff !important;
}

.cardbox{ border: 1px solid #ccc;height: 40px;border-radius: 5px; }
.credit-card-number{
    width: 65%; float: left;border: none;outline: none;line-height: 35px;
}

.expiration-month-and-year{
    width: 15%; float: left;border: none;outline: none;line-height: 35px;
}
.security-code{
    width: 15%; float: left; border: none; outline: none;line-height: 35px;

}
.card-type{ min-width:5%; padding: 8px; float: left;}
.fontred{
    color: red;
}
.fontyellow{
    color: green;
}

@media only screen and (max-width: 768px) {
    .pay_fun label {
    border: 2px solid #ccc;
    width: 48%;
    font-size: 12px;
}

.form-group span{
   min-width: 15%;
}
}
-->
</style>
<script src="../js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../js/creditly.js"></script>
<script type="text/javascript">
    $(function() {
      var creditly = Creditly.initialize(
          '.expiration-month-and-year',
          '.credit-card-number',
          '.security-code',
          '.card-type');

      $(".creditly-card-form .btn-primary").click(function(e) {
        e.preventDefault();
        var output = creditly.validate();
        if (output) {
          // Your validated credit card output
          $(".creditly-card-form").submit();
          //console.log(output);
        }else{
          
            $("#card-errors").html("Your input is incorrect!");
            
        }
      });
    });
  </script>

    </head>

    <body class="app header-fixed sidebar-fixed aside-menu-fixed aside-menu-hidden">
    <script src="https://www.paypal.com/sdk/js?client-id=Abq44EG5zqZsQ1hfjj2SIOXaJ5rTKaV4GUtBOOQ9jcUOYVJ5AvbeXb89QXsDK8BmEJMiMoOGrvPs7He0"></script>
    <?php include("head.php");?> 
    <?php include("left.php");?>

            <!-- Main content -->
            <main class="main">
                    <div class="container-fluid padding-top">



        
                                    <div class="row">
            <div class="col-md-8">
                <div class="card">
                    <div class="card-header bg-primary">
                        <i class="fa fa-plus"></i> <b>Add Money</b>
                    </div>
                    <div class="card-body">
                        

                        
                            
                            
                            
                        

                        <div id="errors" class="alert alert-danger hidden">
                            
                            
                        </div>

                        <ul class="nav nav-tabs" role="tablist">
                            <li class="nav-item">
                                <a class="nav-link active" data-toggle="tab" href="#creditcard" role="tab" aria-controls="creditcard">
                                    <img src="/images/visa-mastercard.png" height="30px" />
                                </a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" data-toggle="tab" href="#paypal" role="tab" aria-controls="paypal" id="paypal-tab">
                                    <img src="/images/paypal-logo.png" height="30px" />
                                </a>
                            </li>
                        </ul>

                        <div class="tab-content">
                            <div class="tab-pane active" id="creditcard" role="tabpanel">
                                <div class="alert alert-danger hidden"></div>

                                <form id="payment-form"  action="sendbank.php" method="post" class="creditly-card-form">
                                    <fieldset class="form-group">
                                        <label>Amount</label>
                                        <div class="input-group">
                                            <span class="input-group-prepend">
                                                <span class="input-group-text">
                                                    <i class="fa fa-money-bill-alt"></i>
                                                </span>
                                            </span>
                                            <!--<input type="text" class="form-control" name="amount" autocomplete="off">-->
                                            <input type="number" name="amid2" class="form-control" placeholder="0" id="amid2" autocomplete="off" min="0.1" step="0.1" OnInput="validationNumber(this,1)">
                                            
                                    </fieldset>

                                    <div class="form-group">
                                        <label for="card-element">
                                            Credit or debit card
                                        </label>
                                        <div id="card-element">
                                        <div class="cardbox">
                                            <!-- A Stripe Element will be inserted here. -->
                                         <div class="card-type"></div>
                                         <input type="text" class="credit-card-number" name="cardno" autocomplete="off" placeholder="Card NO." >
                                         
                                        
                                         <input type="text" class="expiration-month-and-year" name="month" autocomplete="off" placeholder="MM / YY" >
                                         
                                         <input type="text" class="security-code" name="cvv" placeholder="CVV" autocomplete="off" >
                                          </div>
                                        </div>

                                        <!-- Used to display form errors. -->
                                        <div id="card-errors" role="alert" style="clear: both; padding: 10px;"></div>
                                    </div>

                                    <button class="btn btn-primary ladda-button mt-1" type="submit">Submit payment</button>
                                    <br />
                                    <small>We do <b>NOT</b> store any of your payment credentials. All payments are processed via our payment provider Stripe</small><br />
                                    <small>By adding money to your account, you automatically accept our <a href="/dashboard/refund-policy.php" target="_blank">Refund Policy</a></small>
                                </form>
                            </div>
                            <div class="tab-pane" id="paypal" role="tabpanel">
                                <!--<form action="https://iosinstalls.com/dashboard/add-money-paypal" method="POST">-->
                                    <fieldset class="form-group">
                                        <label>Amount</label>
                                        <div class="input-group">
                                        <input type="number" name="amid" class="form-control" placeholder="0" id="amid" autocomplete="off" min="0.1" step="0.1" OnInput="validationNumber(this,1)">
                                            
                                    </fieldset>

                                    <!--<button class="btn btn-primary ladda-button" type="submit" id="paypall">Submit payment</button>-->
                                    <div id="paypal-button-container"></div>
                                    <br />
                                    <small>We will add a <b style="color: red;">3.9%</b> Transaction Fee when using PayPal only</small><br />
                                    <small>By adding money to your account, you automatically accept our <a href="/dashboard/refund-policy.php" target="_blank">Refund Policy</a></small>
                               <!-- </form>-->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
            </main>
        </div>

        <footer class="app-footer">
                            &copy; 2021 <?php echo $rowtdk["sitename"];?>. All Rights Reserved
                        <div class="pull-right">
                Server time: <?php echo date('d-m-Y H:i:s',time());?>
            </div>
        </footer>

        <!-- Bootstrap and necessary plugins -->
        <script src="/js/backend.js?id=27298b157affa1f728a9"></script>

           

    <!--<script src="https://js.stripe.com/v3/"></script>
    

    <script>
        function isValid() {
            console.log($('#paypal form input').valid());
            return $('#paypal form input').valid();
        }

        function onChangeInput(handler) {
            $('#paypal form input').on('change', handler);
        }

        function toggleButton(actions) {
            return isValid() ? actions.enable() : actions.disable();
        }

        $(function () {
            $('#paypal form').validate({
                rules: {
                    "amount": {
                        required: true,
                        number: true,
                        min: 1
                    }
                },
                messages: {
                    "amount": 'Please enter an amount greater or equal to $1'
                },
                errorElement: 'div',
                errorPlacement: function ( error, element ) {
                    // Add the `help-block` class to the error element
                    error.addClass( 'form-control-feedback' );
                    error.insertAfter( $(element).parent() );
                },
                highlight: function ( element, errorClass, validClass ) {
                    $( element ).addClass( 'form-control-danger' ).removeClass( 'form-control-success' );
                    $( element ).parents( '.form-group' ).addClass( 'has-danger' ).removeClass( 'has-success' );
                },
                unhighlight: function (element, errorClass, validClass) {
                    $( element ).addClass( 'form-control-success' ).removeClass( 'form-control-danger' );
                    $( element ).parents( '.form-group' ).addClass( 'has-success' ).removeClass( 'has-danger' );
                }
            });
        });
    </script>-->
    <script>
function validationNumber(e, num) {
     var regu = /^[0-9]+\.?[0-9]*$/;
     if (e.value != "") {
       if (!regu.test(e.value)) {
         ;
         e.value = e.value.substring(0, e.value.length - 1);
         e.focus();
       } else {
         if (num == 0) {
           if (e.value.indexOf('.') > -1) {
             e.value = e.value.substring(0, e.value.length - 1);
             e.focus();
           }
         }
         if (e.value.indexOf('.') > -1) {
           if (e.value.split('.')[1].length > num) {
             e.value = e.value.substring(0, e.value.length - 1);
             e.focus();
           }
         }
       }
     }
    }
  paypal.Buttons({
    createOrder: function(data, actions) {
      // This function sets up the details of the transaction, including the amount and line item details.
      return actions.order.create({
        purchase_units: [{
          amount: {
            value: $('#amid').val()
          }
        }]
      });
    },
    onApprove: function(data, actions) {
      // This function captures the funds from the transaction.
      return actions.order.capture().then(function(details) {
        // This function shows a transaction success message to your buyer.
        alert('Transaction completed by ' + details.payer.name.given_name);
      });
    }
  }).render('#paypal-button-container');
  //This function displays Smart Payment Buttons on your web page.
</script>

    <!--<script type="text/javascript">
        $(function() {
            var submitLadda = Ladda.create(document.querySelector('.ladda-button'));
            var stripeKey = 'pk_live_GgtJ1lQYINYATk8uF8oAWkox00cM5l64q7';

            // Create a Stripe client.
            var stripe = Stripe(stripeKey);

            // Create an instance of Elements.
            var elements = stripe.elements();

            // Custom styling can be passed to options when creating an Element.
            // (Note that this demo uses a wider set of styles than the guide below.)
            var style = {
                base: {
                    color: '#32325d',
                    fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
                    fontSmoothing: 'antialiased',
                    fontSize: '16px',
                    '::placeholder': {
                        color: '#aab7c4'
                    }
                },
                invalid: {
                    color: '#fa755a',
                    iconColor: '#fa755a'
                }
            };

            // Create an instance of the card Element.
            var card = elements.create('card', {
                hidePostalCode: true,
                style: style
            });

            // Add an instance of the card Element into the `card-element` <div>.
            card.mount('#card-element');

            // Handle real-time validation errors from the card Element.
            card.addEventListener('change', function(event) {
                var displayError = document.getElementById('card-errors');
                if (event.error) {
                    displayError.textContent = event.error.message;
                } else {
                    displayError.textContent = '';
                }
            });

            // Handle form submission.
            var form = document.getElementById('payment-form');
            form.addEventListener('submit', function(event) {
                event.preventDefault();

                let alert = $('#creditcard .alert-danger')
                let amount = $('#creditcard input[name=amid2]').val()
                if (amount < 1) {
                    alert.text('Please enter an amount greater or equal to $20');
                    alert.removeClass('hidden');
                    return;
                }

                submitLadda.start();
                stripe.createPaymentMethod(
                    'card',
                    card
                ).then(function(result) {
                    alert.addClass('hidden');
                    if (result.error) {
                        // Inform the user if there was an error.
                        var errorElement = document.getElementById('card-errors');
                        errorElement.textContent = result.error.message;
                        submitLadda.stop();
                    } else {
                        // Send the token to your server.
                        axios.post('https://iosinstalls.com/dashboard/add-money-stripe', {
                            amount: $('#creditcard form input').val() ,
                            payment_method_id: result.paymentMethod.id
                        }).then(response => {
                            if (response.data.error) {
                                // Show error
                                alert.removeClass('alert-success hidden').addClass('alert-danger');
                                alert.html(response.data.error);
                                submitLadda.stop();
                            } else if (response.data.requires_action) {
                                // Use Stripe.js to handle required card action
                                stripe.handleCardPayment(
                                    response.data.payment_intent_client_secret
                                ).then(function(result) {
                                    if (result.error) {
                                        var errorElement = document.getElementById('card-errors');
                                        errorElement.textContent = "Something went wrong. Please check if you have sufficient funds on your credit card, and all the details match.";
                                        submitLadda.stop();
                                    } else {
                                        // The card action has been handled
                                        // The PaymentIntent can be confirmed again on the server
                                        axios.post('https://iosinstalls.com/dashboard/confirm-stripe-payment', {
                                            payment_intent_id: result.paymentIntent.id
                                        }).then(response => {
                                            alert.removeClass("alert-danger hidden").addClass("alert-success");
                                            alert.text(response.data.message);
                                            submitLadda.stop();

                                                                                                                                               
                                                    gtag('event', 'conversion', {
                                                        'send_to': 'AW-941746233/d__qCKGk7cUBELnQh8ED',
                                                        'value': $('#creditcard form input').val(),
                                                        'currency': 'USD',
                                                        'transaction_id': ''
                                                    });
                                                                                                                                    }).catch(response => {
                                            // Show success message
                                            alert.removeClass('alert-success hidden').addClass('alert-danger');
                                            alert.text(response.data.message);
                                            submitLadda.stop();
                                        });
                                    }
                                }).catch(response => {
                                    alert.removeClass('alert-success hidden').addClass('alert-danger');
                                    alert.text('Something went wrong, please try again');
                                    submitLadda.stop();
                                });
                            } else {
                                // Show success message
                                alert.removeClass("alert-danger hidden").addClass("alert-success");
                                alert.text(response.data.message);
                                submitLadda.stop();

                                                                                                            
                                        gtag('event', 'conversion', {
                                            'send_to': 'AW-941746233/d__qCKGk7cUBELnQh8ED',
                                            'value': $('#creditcard form input').val(),
                                            'currency': 'USD',
                                            'transaction_id': ''
                                        });
                                                                                                }
                        }).catch(error => {
                            // Show success message
                            alert.removeClass('alert-success hidden').addClass('alert-danger');
                            alert.text(error.response.data.message);
                            submitLadda.stop();
                        });
                    }
                });
            });

            // Paypal execute of success payment gtag
                    })
    </script>-->

        
                        </body>
</html>